package algotithm.jianzhioffer.test11;

/**
 * @author zhouyanxiang
 * @Date 2020-12-2020/12/14-14:58
 */
public class Solution {

    public static void main(String[] args) {
        int[] nums = {3, 4, 5, 1, 2};
        Solution solution = new Solution();
        System.out.println(solution.minArray(nums));
    }

    public int minArray(int[] nums) {
        int left = 0, right = nums.length - 1;
        while (left < right) {
            int mid = left + (right - left) / 2;
            if (nums[mid] > nums[right]) {
                left = mid + 1;
            } else if (nums[mid] < nums[right]) {
                right = mid;
            } else {
                right--;
            }
        }
        return nums[left];
    }

}
